{% extends "jqmobile/base.html" %}
{% load i18n admin_modify adminmedia jqmobile_tags %}

{% block navbar %}{% get_breadcrumb request.path %}{% endblock %}
{% block title %}{% trans "Password change" %}{% endblock %}

{% block content %}
{# TODO: French translations alre all mixed up with change "MY" password form ... #}
{#<h1>{% trans 'Password change' %}</h1>#}
<form action="{{ form_url }}" method="post" selected="true" class="panel">{% csrf_token %}{% block form_top %}{% endblock %}
    {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
    <h1>{% trans "Change password: " %} {{ original }}</h1>
    
    <div class="ui-bar ui-bar-e">
    	{% blocktrans with original.username as username %}Enter a new password for the user <strong>{{ username }}</strong>.{% endblocktrans %}
    </div>
    {% if form.errors %}
    <p class="errornote">{% blocktrans count form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %} </p>
    {% endif %}
    
    <div class="ui-body ui-body-c">
        <div data-role="fieldcontain">
            <label for="id_new_password1" class="required ui-input-text">{% trans "New password:" %}</label>
            {{ form.password1 }}
            {% if form.password1.errors %}{{ form.password1.errors }}{% endif %}
        </div>
        <div data-role="fieldcontain">
            <label for="id_new_password2" class="required ui-input-text">{% trans "Confirm password:" %}</label>
            {{ form.password2 }}
            {% if form.password2.errors %}{{ form.password2.errors }}{% endif %}
        </div>
        <div data-role="fieldcontain">
            {#<p class="help">{% trans "Enter the same password as above, for verification." %}#}
            <input type="hidden" name="this_is_the_password_form" value="1" />
            <input type="hidden" name="post_data" value="{{ post_data }}" />
       </div>
    </div>
</form>
{% endblock %}

{% block page.footer %}
<div for="footer_id" data-role="footer" class="ui-bar" data-position="fixed" data-backbtn="false">
	<a id="save-object" data-theme="b" data-iconpos="left" data-icon="check" onclick="document.forms[0].submit();">{% trans 'Change my password' %}</a>
	<a id="clear-object" data-theme="b" data-iconpos="left" data-icon="delete" onclick="document.forms[0].reset();" class="ui-btn-delete">{% trans "Clear" %}</a>
	<script>
    $(function(){
		$('#save-object').bind('click', function(){
            $('form:first').submit()
            return false
        })
	})
	</script>
</div>
{% endblock %}
